package com.ruoyi.web.controller.kyhs;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.kysh.entity.TaskPlan;
import com.ruoyi.system.kysh.entity.dto.DailyInfDto;
import com.ruoyi.system.kysh.entity.dto.DailyInfPageDto;
import com.ruoyi.system.kysh.entity.dto.TaskPlanAddDateDto;
import com.ruoyi.system.kysh.entity.dto.TaskPlanDateDto;
import com.ruoyi.system.kysh.service.AcceptInfService;
import com.ruoyi.system.kysh.service.TaskPlanService;
import com.ruoyi.system.kysh.utils.MyTimeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/kyhs/daily-report")
public class DailyReportController {

    @Autowired
    private TaskPlanService taskPlanService;

    @Autowired
    private AcceptInfService acceptInfService;

    @GetMapping("/select-daily-list")
    public AjaxResult selectDailyReportListByDateAndSailings(Date workTime,String sailings,String acceptNum,int page,int pageSize){
        TaskPlanDateDto taskPlanDateDto=taskPlanService.selectDaily(workTime,sailings,acceptNum,page,pageSize);
        return AjaxResult.success("操作成功",taskPlanDateDto);
    }

    @GetMapping("/select-detail-daily-inf")
    public AjaxResult selectDetailDailyInf(Date date){
        if(date==null){
            return AjaxResult.error();
        }
        List<DailyInfDto> dailyInfDtos=taskPlanService.selectDetailDailyInf(date);
        return AjaxResult.success("查询成功",dailyInfDtos);
    }

    @GetMapping("/select-accept-inf")
    public AjaxResult selectAcceptInf(String acceptNum,int page,int pageSize){
        DailyInfPageDto dailyInfPageDto =acceptInfService.selectByAcceptAndPages(acceptNum,page,pageSize);
        return AjaxResult.success(dailyInfPageDto);
    }

    @GetMapping("/select-detail-daily-inf-to-accept")
    public AjaxResult selectDetailDailyInf(Long taskId){
        if(taskId==null){
            return AjaxResult.error();
        }
        DailyInfDto dailyInfDto=taskPlanService.selectDetailDailyInfToAccept(taskId);
        return AjaxResult.success("查询成功",dailyInfDto);
    }


}
